#include <func.h>
#define n 10000000
int main(int argc,char **argv)
{
    int shmid = shmget(IPC_PRIVATE,4096,IPC_CREAT|0600);
    ERROR_CHECK(shmid,-1,"shmget");

    int *i = (int *)shmat(shmid,NULL,0);
    ERROR_CHECK(i,(int *)-1,"shmat");
    

    
    if(!fork())
    {
        for(int j = 0;j<n;++j)
        {
           *i+=1;
        }
    }
    else
    {
        for(int k = 0;k<n;++k)
            *i+=1;
        wait(NULL);
        printf("%d\n",*i);
    }

    return 0;
}

